package com.ofwiki.demo.scheduler.common;


/**
 *
 * @author HuangJS
 * @date 2021/12/27 9:46 上午
 */
public class JobContext {
    public static final int SUCCESS = 200;
    public static final int FAIL = 500;
    private static InheritableThreadLocal<JobContext> contextHolder = new InheritableThreadLocal<>();
    private final long jobId;
    
    private Long processId;
    private final String jobParam;
    private int triggerCode = SUCCESS;
    /**
     * 执行状态:200->默认成功;其它业务自己定义...
     */
    private int handleCode = SUCCESS;
    /**
     * 执行结果说明
     */
    private String handleMsg;


    public JobContext(long jobId, String jobParam) {
        this.jobId = jobId;
        this.jobParam = jobParam;
    }
    
    public Long getProcessId() {
        return processId;
    }
    
    public void setProcessId(Long processId) {
        this.processId = processId;
    }
    
    public int getTriggerCode() {
        return triggerCode;
    }
    
    public void setTriggerCode(int triggerCode) {
        this.triggerCode = triggerCode;
    }
    
    public long getJobId() {
        return jobId;
    }

    public String getJobParam() {
        return jobParam;
    }

    public void setHandleCode(int handleCode) {
        this.handleCode = handleCode;
    }

    public int getHandleCode() {
        return handleCode;
    }

    public void setHandleMsg(String handleMsg) {
        this.handleMsg = handleMsg;
    }

    public String getHandleMsg() {
        return handleMsg;
    }

    public static void setJobContext(JobContext jobContext){
        contextHolder.set(jobContext);
    }

    public static JobContext getJobContext(){
        return contextHolder.get();
    }

}